package com.allwees.bs.module.scm.rest;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.allwees.bs.core.modelbase.vo.R;
import com.allwees.bs.module.core.dynamic.annotation.DynamicInject;
import com.allwees.bs.module.core.rest.BoCrudApi;
import com.allwees.bs.module.oms.constant.EShippingType;
import com.allwees.bs.module.scm.entity.ScmPickOrderSku;
import com.allwees.bs.module.scm.req.PickOrderSkuBackToAllocateReq;
import com.allwees.bs.module.scm.req.PickOrderSkuMarkHaveReq;
import com.allwees.bs.module.scm.req.PickOrderSkuMarkSelloutReq;
import com.allwees.bs.module.scm.req.PickOrderSkuShippingReq;
import com.allwees.bs.module.scm.req.query.ScmPickOrderSkuQueryReq;
import com.allwees.bs.module.scm.service.ScmPickOrderSkuService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
@RequestMapping("/backstage/api/scm/pick_order")
public class ScmPickOrderSkuApi extends BoCrudApi<ScmPickOrderSku, ScmPickOrderSkuService> {

    @DynamicInject(key = "orderItemUuid")
    @GetMapping("/page")
    public R page(Page<ScmPickOrderSku> page, ScmPickOrderSkuQueryReq req) {
        IPage<ScmPickOrderSku> page1 = boService.findPage(page, req);
        return R.ok(page1);
    }

    @PostMapping("/mark_sellout")
    public R markSellout(@RequestBody PickOrderSkuMarkSelloutReq req) {
        boService.markSellout(req);
        return R.ok();
    }

    @PostMapping("/mark_have")
    public R markHave(@RequestBody PickOrderSkuMarkHaveReq req) {
        boService.markHave(req);
        return R.ok();
    }

    @PostMapping("/back_to_allocate")
    public R joinPick(@RequestBody PickOrderSkuBackToAllocateReq req) {
        boService.backToAllocate(req);
        return R.ok();
    }

    @PostMapping("/shipping/{shippingType}")
    public R shipping(@PathVariable EShippingType shippingType, @RequestBody PickOrderSkuShippingReq req) {
        boService.shipping(shippingType, req);
        return R.ok();
    }
}
